package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.home.entity.UserInfo;
import com.rongshu.view.userInfo.entity.AccountInformation;
import com.rongshu.view.userInfo.iview.PersonDetailsView;

import rx.Subscriber;

public class PersonDetailsPresenter extends BasePresenter<PersonDetailsView> {

    public PersonDetailsPresenter(Context context) {
        super(context);
    }

    /**
     * 获取用户资料
     */
    public void getUserInfo(int user_id, String sign) {
        RetorfitService.getUserInfo(user_id, sign)
                .subscribe(new Subscriber<UserInfo>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(UserInfo userInfo) {
                        if (getView() != null) {
                            getView().onUserInfo(userInfo);
                        }
                    }
                });
    }

    /**
     * 获取账号信息(消息、关注、粉丝、获赞、笔友会、卡包、榕树叶数量和用户等创作、阅读级等)
     */
    public void getAccountModel(int user_id, String sign) {
        RetorfitService.getAccountModel(user_id, sign)
                .subscribe(new Subscriber<AccountInformation>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(AccountInformation accountInformation) {
                        if (getView() != null) {
                            getView().onAccountInfo(accountInformation);
                        }
                    }
                });
    }
}
